#include <bits/stdc++.h>

using namespace std;

struct node
{
    int v;
    int cnt;
    unordered_map<int, node *> next;
    node(int a)
    {
        v = a, cnt = 0;
    }
};

int t, n, p;

int dfs(node *q)
{
    if (q == nullptr)
        return 0;
    int ans = q->cnt;
    for (auto i : q->next)
        ans += dfs(i.second);
    return q->cnt = ans;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin >> t;
    while (t--)
    {

        node *tree = new node(' ');
        node *q = tree;
        string s;
        cin >> n;
        bool flag = true;
        for (int i = 0; i < n; i++)
        {
            cin >> s;
            q = tree;
            for (int i = 0; i < s.size(); i++)
            {
                if (q->next[s[i]]){
                    q = q->next[s[i]];
                    if (i == s.size() - 1){
                        flag = false;
                        break;
                    }
                }
                else
                {
                    if (q->cnt)
                    {
                        flag = false;
                        break;
                    }
                    q->next[s[i]] = new node(s[i]), q = q->next[s[i]];
                }
            }
            q->cnt++;
        }
        if (flag)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
